1
2 import java.sql.Connection;
3 import java.sql.DriverManager;
4 import java.sql.ResultSet;
5 import java.sql.Statement;

6
7 /*
8  * To change
this license header, choose License Headers in Project Properties.
9  * To change
this template file, choose Tools | Templates
10  * and open the template
in the editor.
11  */
12
13 /**
14  *
15  * @author MY LAPI
16  */

17 public
class IBLog extends javax.swing.JFrame {
18
19     
/**
20      * Creates
new form IBReg
21      */

22     
public IBLog() {
23         initComponents();
24     }
25
26     
/**
27      * This method
is called from within the constructor to initialize the form.
28      * WARNING: Do NOT modify
this code. The content of this method is always
29      * regenerated
by the Form Editor.
30      */

31     @SuppressWarnings(
"unchecked")
32     
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
33     
private void initComponents() {
34
35         jLabel1 =
new javax.swing.JLabel();
36         jLabel2 =
new javax.swing.JLabel();
37         jTextField1 =
new javax.swing.JTextField();
38         jLabel3 =
new javax.swing.JLabel();
39         jButton1 =
new javax.swing.JButton();
40         jButton2 =
new javax.swing.JButton();
41         jButton3 =
new javax.swing.JButton();
42         jLabel4 =
new javax.swing.JLabel();
43         jPasswordField1 =
new javax.swing.JPasswordField();
44
45         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
46
47         jLabel1.setFont(
new java.awt.Font("Arial Unicode MS", 0, 18)); // NOI18N
48         jLabel1.setText(
"STAR BANK Net Banking");
49
50         jLabel2.setFont(
new java.awt.Font("Arial Unicode MS", 0, 14)); // NOI18N
51         jLabel2.setText(
"UserName");
52
53         jLabel3.setFont(
new java.awt.Font("Arial Unicode MS", 0, 14)); // NOI18N
54         jLabel3.setText(
"Password");
55
56         jButton1.setFont(
new java.awt.Font("Arial Unicode MS", 0, 14)); // NOI18N
57         jButton1.setText(
"Reset");
58         jButton1.addActionListener(
new java.awt.event.ActionListener() {
59             
public void actionPerformed(java.awt.event.ActionEvent evt) {
60                 jButton1ActionPerformed(evt);
61             }
62         });
63
64         jButton2.setFont(
new java.awt.Font("Arial Unicode MS", 0, 14)); // NOI18N
65         jButton2.setText(
"Login");
66         jButton2.addActionListener(
new java.awt.event.ActionListener() {
67             
public void actionPerformed(java.awt.event.ActionEvent evt) {
68                 jButton2ActionPerformed(evt);
69             }
70         });
71
72         jButton3.setText(
"Create an Account");
73         jButton3.addActionListener(
new java.awt.event.ActionListener() {
74             
public void actionPerformed(java.awt.event.ActionEvent evt) {
75                 jButton3ActionPerformed(evt);
76             }
77         });
78
79         jLabel4.setForeground(
new java.awt.Color(255, 0, 51));
80
81         jPasswordField1.addActionListener(
new java.awt.event.ActionListener() {
82             
public void actionPerformed(java.awt.event.ActionEvent evt) {
83                 jPasswordField1ActionPerformed(evt);
84             }
85         });
86
87         javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(getContentPane());
88         getContentPane().setLayout(layout);
89         layout.setHorizontalGroup(
90             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
91             .addGroup(layout.createSequentialGroup()
92                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
93                     .addGroup(layout.createSequentialGroup()
94                         .addGap(
89, 89, 89)
95                         .addComponent(jLabel1))
96                     .addGroup(layout.createSequentialGroup()
97                         .addGap(
52, 52, 52)
98                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
99                             .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE,
79, javax.swing.GroupLayout.PREFERRED_SIZE)
100                             .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE,
79, javax.swing.GroupLayout.PREFERRED_SIZE))
101                         .addGap(
35, 35, 35)
102                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
103                             .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE,
173, javax.swing.GroupLayout.PREFERRED_SIZE)
104                             .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE,
201, javax.swing.GroupLayout.PREFERRED_SIZE)
105                             .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING,
false)
106                                 .addComponent(jPasswordField1, javax.swing.GroupLayout.Alignment.LEADING)
107                                 .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
108                                     .addComponent(jButton1)
109                                     .addGap(
37, 37, 37)
110                                     .addComponent(jButton2))))))
111                 .addContainerGap(
19, Short.MAX_VALUE))
112             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
113                 .addGap(
0, 0, Short.MAX_VALUE)
114                 .addComponent(jButton3)
115                 .addGap(
78, 78, 78))
116         );
117         layout.setVerticalGroup(
118             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
119             .addGroup(layout.createSequentialGroup()
120                 .addContainerGap()
121                 .addComponent(jLabel1)
122                 .addGap(
24, 24, 24)
123                 .addComponent(jLabel4)
124                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
125                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
126                     .addComponent(jLabel2)
127                     .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
128                 .addGap(
18, 18, 18)
129                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
130                     .addComponent(jLabel3)
131                     .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
132                 .addGap(
13, 13, 13)
133                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
134                     .addComponent(jButton2)
135                     .addComponent(jButton1))
136                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
40, Short.MAX_VALUE)
137                 .addComponent(jButton3)
138                 .addContainerGap())
139         );
140
141         pack();
142     }
// </editor-fold>//GEN-END:initComponents
143
144     
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
145                 IBReg pb1=
new IBReg();
146                 IBLog pb2=
new IBLog();
147                 pb2.setVisible(
false);
148                 pb1.setVisible(
true);
149                 dispose();
150     }
//GEN-LAST:event_jButton3ActionPerformed
151
152     
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
153        
try{
154             Class.forName(
"com.mysql.jdbc.Driver").newInstance();
155             Connection cn=DriverManager.getConnection(
"jdbc:mysql://localhost:3306/bank","root","");
156             
157             Statement smt=cn.createStatement();
158             ResultSet rs=smt.executeQuery(
"select uid from user where email='"+jTextField1.getText()+"' and password='"+jPasswordField1.getText()+"'");
159            
int pb;
160             
if(rs.next()){
161                 pb=rs.getInt(
1);
162         UserDesh pb1=
new UserDesh(pb);
163                 IBLog pb2=
new IBLog();
164                 pb2.setVisible(
false);
165                 pb1.setVisible(
true);
166                 dispose();
167             }
else{
168                 jLabel4.setText(
"** Wrong Username OR Password **");
169             }
170         }
catch(Exception e){jLabel4.setText(e.getMessage());}
171     }
//GEN-LAST:event_jButton2ActionPerformed
172
173     
private void jPasswordField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jPasswordField1ActionPerformed
174         
// TODO add your handling code here:
175     }
//GEN-LAST:event_jPasswordField1ActionPerformed
176
177     
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
178         jTextField1.setText(
"");
179         jPasswordField1.setText(
"");
180     }
//GEN-LAST:event_jButton1ActionPerformed
181
182     
/**
183      * @param args the command line arguments
184      */

185     
public static void main(String args[]) {
186         
/* Set the Nimbus look and feel */
187         
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
188         
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
189          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
190          */

191         
try {
192             
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
193                 
if ("Nimbus".equals(info.getName())) {
194                     javax.swing.UIManager.setLookAndFeel(info.getClassName());
195                     
break;
196                 }
197             }
198         }
catch (ClassNotFoundException ex) {
199             java.util.logging.Logger.getLogger(IBReg.
class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
200         }
catch (InstantiationException ex) {
201             java.util.logging.Logger.getLogger(IBReg.
class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
202         }
catch (IllegalAccessException ex) {
203             java.util.logging.Logger.getLogger(IBReg.
class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
204         }
catch (javax.swing.UnsupportedLookAndFeelException ex) {
205             java.util.logging.Logger.getLogger(IBReg.
class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
206         }
207         
//</editor-fold>
208
209         
/* Create and display the form */
210         java.awt.EventQueue.invokeLater(
new Runnable() {
211             
public void run() {
212                 
new IBLog().setVisible(true);
213             }
214         });
215     }
216
217     
// Variables declaration - do not modify//GEN-BEGIN:variables
218     
private javax.swing.JButton jButton1;
219     
private javax.swing.JButton jButton2;
220     
private javax.swing.JButton jButton3;
221     
private javax.swing.JLabel jLabel1;
222     
private javax.swing.JLabel jLabel2;
223     
private javax.swing.JLabel jLabel3;
224     
private javax.swing.JLabel jLabel4;
225     
private javax.swing.JPasswordField jPasswordField1;
226     
private javax.swing.JTextField jTextField1;
227     
// End of variables declaration//GEN-END:variables
228 }


Gõ tìm kiếm nhanh...